# -*- coding: utf-8 -*-

# Define here the models for your scraped items
#
# See documentation in:
# https://doc.scrapy.org/en/latest/topics/items.html

import scrapy


class TaobaoItem(scrapy.Item):
    # define the fields for your item here like:
    # name = scrapy.Field()
    pass


class TaoBaoItem(scrapy.Item):
    title = scrapy.Field()
    addr = scrapy.Field()
    oprice = scrapy.Field()
    pprice = scrapy.Field()
    img_url = scrapy.Field()
    company = scrapy.Field()
    paynum = scrapy.Field()

    def get_insert_sql(self):
        insert_sql = 'INSERT INTO taobao(title,addr,oprice,pprice,img_url,company,paynum) VALUES(%s,%s,%s,%s,%s,%s,%s)'
        data = (self['title'],self['addr'],self['oprice'],self['pprice'],self['img_url'],self['company'],self['paynum'])
        return (insert_sql,data)